import json  #json格式转换
from flask import Flask,request #导入两大工具
app = Flask(__name__)# 创建一个应用对象
@app.route("/index")# 定义视图函数，设置路由规则，指名路径，返回首页
def index():
    return "hello mock"
@app.route("/api/sys/login",methods=["POST"]) #模仿第二页面：登录页面
def login():
    result = json.loads(request.get_data().decode("utf-8")) # 字典形式 的请求体数据
    mobile = result.get("mobile")
    password = result.get("password")
    print(mobile,password)
    if mobile =="13800000002" and password == "123456":
        data = {"success": True,"code": 10000,"message":"操作成功！","token": "ajsdfj-12312-szs-fd-dfs125"}
    else:
        data = {"success": False,"code": 99999,"message": "抱歉，系统繁忙，请稍后重试","token": None}
    return data
if __name__ == '__main__':
    app.run()# 启动WEB服务器
#post   http://127.0.0.1:5000/api/sys/login   {"mobile":"13800000002", "password":"123456"}
#get    http://127.0.0.1:5000/index